import java.util.*;

/**
 * @author LKQ
 * @date 2022/3/21 9:37
 * @description
 */
public class Solution2 {
    public static void main(String[] args) {

    }
    public boolean canThreePartsEqualSum(int[] arr) {
        int sum = 0;
        for(int a: arr) {
            sum+= a;
        }
        if (sum % 3 != 0) {
            return false;
        }
        int target = sum / 3;
        int cur = 0, i = 0, n = arr.length;
        while ( i < n) {
            cur+= arr[i];
            if (cur == target) {
                break;
            }
            i++;
        }
        if (cur != target) {
            return false;
        }
        int j = i + 1;
        while (j + 1 < n) {
            cur += arr[j];
            if (cur == target * 2) {
                return true;
            }
            j++;
        }
        return false;
    }
}
